#元组的内容不可以修改

#定义元组
t1 = (1,"xixi",True)
t2 = ()
t3 = tuple()

print(f"{type(t1)},{t1}")
print(f"{type(t2)},{t2}")
print(f"{type(t3)},{t3}")


#定义单个元素
t4 = ("hello",)#不写逗号是str类型
print(f"{type(t4)},{t4}")

#元组的嵌套
t5 = ((1,2,3),(4,5,6))
print(f"{type(t5)},{t5}")

#通过索引取出元素
num = t5[1][1]
print(num)

#元组的操作 index查找方法
t6 = ("xixi","hehe","haha")
index = t6.index("haha")
print(index)

#元组的操作 count统计方法
t7 = ("xixi","hehe","haha","haha","hehe")
count = t7.count("haha")
print(count)

#元组的操作 len函数统计元组元素数量
t8 = ("xixi","hehe","haha","haha","hehe")
num1 = len(t8)
print(num1)

# 元组的遍历 while
i = 0
while i < len(t8):
    print(t8[i])
    i += 1

# 元组的遍历  for
for item in t8:
    print(item)